﻿<style type="text/css">
    .auto-style1 {
        width: 400px;
    }

    .easyui-textbox {
        width: 430px;
    }

    .auto-style2 {
        width: 150px;
    }

    .easyui-combobox {
        width: 430px;
    }
</style>
@{
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
    <title>项目评估</title>
    <link href="~/css/css_1.css" rel="stylesheet" />
    <link rel="stylesheet" type="text/css" href="../../easyUI/themes/default/easyui.css">
    <link rel="stylesheet" type="text/css" href="../../easyUI/themes/icon.css">
    <script type="text/javascript" src="../../easyUI/jquery.min.js"></script>
    <script type="text/javascript" src="../../easyUI/jquery.easyui.min.js"></script>
    <script>
        $(function () {
            jiazai();
        })

        //加载信息
        function jiazai() {
            $.ajax({
                url: "http://localhost:25744/api/Project",
                type: "get",
                dataType: "json",
                data: { basic_State: 91, evaluation: 5 },
                success: function (data1) {
                    var msg = eval(data1);
                    $('#dg').datagrid({
                        data: msg
                    });
                }
            })
        }
        //下拉框
        function sel() {
            $.ajax({
                url: "http://localhost:25744/api/Dictionary?Dictionary_Type=估价目的",
                dataType: "json",
                type: "get",
                success: function (obj) {
                    var data = eval(obj);
                    $("#basic_Evaluation").combobox({
                        data: data,
                        valueField: 'dictionary_Id',
                        textField: 'dictionary_Name'
                    })
                }
            })
        }

        //打开开始评估页面
        function tian() {
            var myDate = new Date();
            var row = $('#dg').datagrid('getSelected');
            if (row) {
                $("#basic_id").textbox("setValue", row.basic_id);
                $("#survey_StartTime").textbox("setValue", row.survey_StartTime);
                $("#survey_EndTime").textbox("setValue", row.survey_EndTime);
                $("#basic_ValueTime").textbox("setValue", myDate.toLocaleString());
                $("#basic_Acreage").textbox("setValue", row.basic_Acreage);
                sel();
                $('#w').window('open');
            }
        }

        //进行评估
        function add() {
            var basic_UnitPrice = $("#basic_UnitPrice").textbox('getValue');
            var basic_Acreage = $("#basic_Acreage").textbox('getValue');
            $.ajax({
                url: "http://localhost:25744/api/Assessment",
                type: "put",
                data: {
                    basic_id: $("#basic_id").val(),
                    basic_Evaluation: $("#basic_Evaluation").combobox('getValue'),
                    basic_UnitPrice: $("#basic_UnitPrice").val(),
                    basic_Total: basic_UnitPrice * basic_Acreage,
                    basic_State:92
                },
                success: function (sql) {
                    if (sql > 0) {
                        alert('评估成功');
                        $('#w').window('close');
                        jiazai();
                    }
                    else {
                        alert('评估失败')
                    }
                }
            })
        }

    </script>
</head>
<body class="bb1">
    <a href="javascript:void(0)" class="easyui-linkbutton" onclick="tian()">项目评估</a>
    <div style="width:100%;height:100%">
        <table class="easyui-datagrid" style="width:90%;height:80%" id="dg"
               data-options="url:'datagrid_data.json',fitColumns:true,singleSelect:true">
            <thead>
                <tr>
                    <th data-options="field:'ck',checkbox:true"></th>
                    <th data-options="field:'basic_id',width:60,align:'center'">项目号</th>
                    <th data-options="field:'projectNumber',width:80,align:'center'">项目编号</th>
                    <th data-options="field:'the_Department',width:80,align:'center'">所属部门</th>
                    <th data-options="field:'survey',width:80,align:'center'">勘察人</th>
                    <th data-options="field:'survey_StartTime',width:120,align:'center'">勘察开始时间</th>
                    <th data-options="field:'survey_EndTime',width:120,align:'center'">勘察结束时间</th>
                    <th data-options="field:'basic_CreateTime',width:120,align:'center'">登记日期</th>
                    <th data-options="field:'basic_UnitPrice',width:120,align:'center'">建议评估单价（元）</th>
                    <th data-options="field:'basic_State',width:60,align:'center'">项目状态</th>
                </tr>
            </thead>
        </table>
    </div>
    <div id="w" class="easyui-window" title="项目评估" data-options="modal:true,closed:true,iconCls:'icon-save'" style="width:auto;height:60%;padding:10px;">
        <form>
            <table>
                <tr hidden="hidden">
                    <td>项目号：</td>
                    <td>
                        <input id="basic_id" class="easyui-textbox" type="text" name="name">
                    </td>
                </tr>
                <tr >
                    <td>估价目的：</td>
                    <td>
                        <select id="basic_Evaluation" class="easyui-combobox" name="dept"  style="width:100%"></select>
                    </td>
                </tr>
                <tr>
                    <td>勘察起始日期：</td>
                    <td>
                        <input id="survey_StartTime" class="easyui-textbox" type="text" name="name" readonly="readonly">
                    </td>
                </tr>
                <tr>
                    <td>勘察结束日期：</td>
                    <td>
                        <input id="survey_EndTime" class="easyui-textbox" type="text" name="name" readonly="readonly">
                    </td>
                </tr>
                <tr>
                    <td>价值时点：</td>
                    <td>
                        <input id="basic_ValueTime" class="easyui-textbox" type="text" name="name" readonly="readonly">
                    </td>
                </tr>
                <tr>
                    <td>评估单价（元/㎡）：</td>
                    <td>
                        <input id="basic_UnitPrice" class="easyui-textbox" type="text" name="name" >
                    </td>
                </tr>
                <tr>
                    <td>建筑面积（m³）：</td>
                    <td>
                        <input id="basic_Acreage" class="easyui-textbox" type="text" name="name" readonly="readonly">
                    </td>
                </tr>
                <tr hidden="hidden">
                    <td>评估总值（万元）：</td>
                    <td>
                        <input id="basic_Total" class="easyui-textbox" type="text" name="name" readonly="readonly">
                    </td>
                </tr>
                <tr>
                    <td>Excel估价计算单：</td>
                    <td>
                        <input id="basic_Excl" class="easyui-textbox" type="text" name="name">
                    </td>
                </tr>
                <tr>
                    <td>其他附件（多个文件请使用压缩包）</td>
                    <td>
                        <input id="basic_Enclosure" class="easyui-textbox" type="text" name="name">
                    </td>
                </tr>
                <tr>
                    <td></td>
                    <td>
                        <a href="javascript:void(0)" class="easyui-linkbutton" onclick="add()" id="tian">评估</a>
                        <a href="javascript:void(0)" class="easyui-linkbutton" onclick="$('#w').window('close')">取消</a>
                    </td>
                </tr>
            </table>
        </form>

    </div>
</body>
</html>

